package com.lancoo.znbkxx.teacher.aibkTestCoach.questionToMark.aibkMarkJdt

import android.content.Context
import android.os.Handler
import android.util.Log
import android.view.View
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.viewpager.widget.ViewPager
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkDialog.ShowDialogTools
import com.lancoo.znbkxx.teacher.aibkTestCoach.auidoPlayer.AudioPlayer
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.EvalBody.QuesListEntity
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.QuesMarkDeatil
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.SubjectData
import com.lancoo.znbkxx.teacher.aibkTestCoach.questionToMark.AibkQuesMarkActivity
import com.lancoo.znbkxx.teacher.aibkTestCoach.questionToMark.MarkFragmentParentView
import com.lancoo.znbkxx.teacher.aibkTestCoach.questionToMark.adapter.MyVpFragmentPagerAdapter
import com.lancoo.znbkxx.teacher.aibkTestCoach.questionToMark.adapter.SubjectAdapter
import com.lancoo.znbkxx.teacher.help.KeyboardStateObserverHelp
import com.lancoo.znbkxx.teacher.utils.DensityUtils
import com.lancoo.znbkxx.teacher.utils.WebStyleUtils
import com.lancoo.znbkxx.teacher.utils.WebStyleUtils.setWebImageClick
import com.lancoo.znbkxx.teacher.widget.KWebView
import kotlinx.android.synthetic.main.aibk_fragment_mark_model_splitlayout.view.*
import kotlinx.android.synthetic.main.aibk_include_article_view.view.*
import kotlinx.android.synthetic.main.aibk_include_loading_refresh.view.*
import kotlinx.android.synthetic.main.aibk_include_mark_view.*
import kotlinx.android.synthetic.main.aibk_include_parent_audioplayer_a.view.*
import kotlinx.android.synthetic.main.aibk_include_ques_answer_view.view.*
import kotlinx.android.synthetic.main.aibk_include_ques_web_ask_view.view.*
import kotlinx.android.synthetic.main.aibk_include_question_information_view.view.*
import java.text.SimpleDateFormat
import java.util.*

class MarkFragmentJdt(
        val indexA: Int,
        val indexB: Int,
        val activity: AibkQuesMarkActivity,
        var quesId: String,
        var startIndex: String
) : KBaseFragment(), View.OnClickListener {
    private var rootView: View? = null
    private lateinit var quesMarkDeatil: QuesMarkDeatil
    private var isAddView = false
    private var fragmentList: MutableList<Fragment>? = ArrayList()
    private var itemList: ArrayList<SubjectData> = ArrayList()
    private var childItemList: ArrayList<SubjectData> = ArrayList()
    private lateinit var subjectAdapter: SubjectAdapter
    private var lastPosition = 0
    private var typeNo = ""

    override fun createLayout(): Int {
        return R.layout.aibk_fragment_mark_model_splitlayout
    }

    override fun initView(view: View?) {
        rootView = view
        rootView!!.RlGifLoading.visibility = View.VISIBLE
        rootView!!.RlAudioPlayer.visibility = View.GONE
        rootView!!.RlArticleView.visibility = View.GONE
        rootView!!.IvPlayOrPause.setOnClickListener(this)
        adjustPan()
    }

    //调整布局高度
    private fun adjustPan() {
        val screenHeight = DensityUtils.getScreenHeight(getActivity())
        rootView!!.sp_layout.setmSplitHeight(screenHeight * 2 / 5)
        KeyboardStateObserverHelp.getKeyboardStateObserver(getActivity()).setKeyboardVisibilityListener(object : KeyboardStateObserverHelp.OnKeyboardVisibilityListener {
            override fun onKeyboardShow() {
                rootView!!.sp_layout.setmSplitHeight(300)
            }

            override fun onKeyboardHide() {
                rootView!!.sp_layout.requestFocus()
                rootView!!.sp_layout.setmSplitHeight(screenHeight * 2 / 5)
            }
        })
    }

    private fun initSubjectAdapter() {
        setSubjectData()
        itemList[0].isSelect = true
        subjectAdapter = SubjectAdapter(activity, itemList)
        subjectAdapter.setOnItemClickListener(object : SubjectAdapter.OnItemClickListener {
            override fun onItemClickPlay(position: Int, view: View?) {
                VpAnswer.setCurrentItem(position, true)
            }
        })
        rv_subject.layoutManager = GridLayoutManager(context, 5)
        rv_subject.adapter = subjectAdapter
    }

    private fun setChildItemList() {
        childItemList.clear()
        for (i in quesMarkDeatil.QuesDetail.ChildList.indices) {
            if (quesMarkDeatil.QuesDetail.ChildList[i].SortIndexType == 0) {
                var item = SubjectData()
                item.childIndex = quesMarkDeatil.QuesDetail.ChildList[i].ItemList[0].SortIndex
                childItemList.add(item)
            } else {
                for (j in quesMarkDeatil.QuesDetail.ChildList[i].ItemList.indices) {
                    var item = SubjectData()
                    item.childIndex = quesMarkDeatil.QuesDetail.ChildList[i].ItemList[j].SortIndex
                    childItemList.add(item)
                }
            }
        }
    }

    private fun setSubjectData() {
        itemList.clear()
        if (typeNo == "U") { //对改错题展示的专门适配
            var item = SubjectData()
            var size = quesMarkDeatil.QuesDetail.ChildList[0].ItemList.size
            if (size > 1) {
                item.childIndex = quesMarkDeatil.QuesDetail.ChildList[0].ItemList[0].SortIndex + "-" + quesMarkDeatil.QuesDetail.ChildList[0].ItemList[size - 1].SortIndex
            } else {
                item.childIndex = quesMarkDeatil.QuesDetail.ChildList[0].ItemList[0].SortIndex

            }
            itemList.add(item)
        } else {
            for (i in quesMarkDeatil.QuesDetail.ChildList.indices) {
                if (quesMarkDeatil.QuesDetail.ChildList[i].SortIndexType == 0) {
                    var item = SubjectData()
                    item.childIndex = quesMarkDeatil.QuesDetail.ChildList[i].ItemList[0].SortIndex
                    itemList.add(item)
                } else {
                    for (j in quesMarkDeatil.QuesDetail.ChildList[i].ItemList.indices) {
                        var item = SubjectData()
                        item.childIndex = quesMarkDeatil.QuesDetail.ChildList[i].ItemList[j].SortIndex
                        itemList.add(item)
                    }
                }
            }
        }
    }

    /*
    * 显示试题内容
    * */
    private fun showQuestionView() {

        //是否显示来源
        var resource = quesMarkDeatil.QuesDetail.Resource
        if (resource.isEmpty()) {
            rootView!!.IncludeQuesInformationView.visibility = View.GONE
        } else {
            rootView!!.IncludeQuesInformationView.visibility = View.VISIBLE
            rootView!!.IncludeQuesInformationView.TvSourceFrom.text = "来源: $resource"
            //隐藏试题准确率
            rootView!!.IncludeQuesInformationView.TvScoreRate.visibility = View.GONE
        }

        //加载题干内容

        if (typeNo == "G" || typeNo == "S") {//x:听力简答
            var timeLength = quesMarkDeatil.QuesDetail.QuesAudio.TimeLength
            val format = SimpleDateFormat("mm:ss", Locale.CHINA)
            rootView!!.TvAudioTotalTime.text = format.format(timeLength * 1000)
            rootView!!.RlAudioPlayer.visibility = View.VISIBLE
            var article = quesMarkDeatil.QuesDetail.QuesAudio.Article
            article = "听力原文：<br>$article"
            if (typeNo == "S") {
                article = "$article<br>"
                val childListSize = quesMarkDeatil.QuesDetail.ChildList.size
                for (c in 0 until childListSize) {
                    val SortIndex = quesMarkDeatil.QuesDetail.ChildList[c].ItemList[0].SortIndex
                    val SortIndexType = quesMarkDeatil.QuesDetail.ChildList[c].SortIndexType
                    article = article + SortIndex + ". " + quesMarkDeatil.QuesDetail.ChildList[c].ChildAsk
                }
                article += getTlTkAnalysisAndAnswer()
            }

            if (WebStyleUtils.hasTable(article)) {
                WebStyleUtils.showWebViewCssStyle(activity, rootView!!.WvAsk, article, false)
            } else {
                WebStyleUtils.showWebViewCssStyle(activity, rootView!!.WvAsk, article, true)
            }

        } else {
            var ask = quesMarkDeatil.QuesDetail.QuesBody
            if (typeNo == "Q" ||
                    typeNo == "d" ||
                    typeNo == "g" ||
                    typeNo == "b" ||
                    typeNo == "V" ||
                    typeNo == "X" ||
                    typeNo == "N" ||
                    typeNo == "U") {
                val childAsk = quesMarkDeatil.QuesDetail.ChildList[0].ChildAsk
                if (typeNo == "Q") {
                    ask = "$ask<br>$childAsk" + getItemAnalysisAndAnswer()
                } else if (typeNo == "g") {
                    quesMarkDeatil.QuesDetail.ChildList.forEach {
                        ask = "$ask<br>${it.ChildAsk}<br>"
                    }
                    ask += getItemAnalysisAndAnswer()
                } else {
                    ask = childAsk + getItemAnalysisAndAnswer()
                }
            }
            if (WebStyleUtils.hasTable(ask)) {
                WebStyleUtils.showWebViewCssStyle(activity, rootView!!.WvAsk, ask, false)
            } else {
                WebStyleUtils.showWebViewCssStyle(activity, rootView!!.WvAsk, ask, true)
            }
            rootView!!.WvAsk.addJavascriptInterface(
                    JSInterface(
                            activity,
                            WebStyleUtils.returnImageUrlsFromHtml(ask)
                    ), "Android"
            )
        }

        rootView!!.WvAsk.webViewClient = object : WebViewClient() {
            override fun onPageFinished(view: WebView, url: String) {
                super.onPageFinished(view, url)
                rootView!!.RlWebLoading.visibility = View.GONE
                setWebImageClick(view, "Android")
                val childListSize = quesMarkDeatil.QuesDetail.ChildList.size
                for (a in 0 until childListSize) {
                    val itemListSize = quesMarkDeatil.QuesDetail.ChildList[a].ItemList.size
                    for (b in 0 until itemListSize) {
                        val itemSortIndex = quesMarkDeatil.QuesDetail.ChildList[a].ItemList[b].ItemSortIndex
                        rootView!!.WvAsk.loadUrl("javascript:setBackGroundColor('" + "blank" + itemSortIndex +
                                "','" + "#00000000" + "','" + "0px" + "','" + "1px solid #848484" + "')")
                        rootView!!.WvAsk.loadUrl(
                                "javascript:CalledByJavaCodeWithPara('" + "blank" + itemSortIndex
                                        + "','" + "<font color=\"#00afff\">"
                                        + "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" + "</font>')"
                        )
                    }
                }
            }
        }

        rootView!!.WvAsk.setOnScrollChangeListener(object : KWebView.OnScrollChangeListener {
            override fun onPageEnd(l: Int, t: Int, oldl: Int, oldt: Int) {}

            override fun onPageTop(l: Int, t: Int, oldl: Int, oldt: Int) {}

            override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {}
        })

        //加载作答区域
        fragmentList = ArrayList<Fragment>()
        resetStuAnswer()
        val mAdapter = MyVpFragmentPagerAdapter(childFragmentManager, fragmentList as ArrayList<Fragment>)
        rootView!!.VpAnswer.adapter = mAdapter
        rootView!!.VpAnswer.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {

            }

            override fun onPageSelected(position: Int) {
                itemList[lastPosition].isSelect = false
                itemList[lastPosition].isShowMark = false
                itemList[position].isSelect = true
                //当前显示
                setStuAnswer(lastPosition)
                //用于保存评阅
                doEvalJob(lastPosition)
                resetStuAnswer()
                subjectAdapter.notifyDataSetChanged()
                VpAnswer.adapter?.notifyDataSetChanged()
                lastPosition = position
            }

            override fun onPageScrollStateChanged(state: Int) {}
        })
    }

    private fun resetStuAnswer() {
        fragmentList!!.clear()
        var ChildListSize = quesMarkDeatil.QuesDetail.ChildList.size
        if (typeNo == "U") {
            (fragmentList as ArrayList<Fragment>)
                    .add(MarkFragmentParentView(activity, null, quesMarkDeatil.StuAnswerList!!, 0, 0, typeNo))
        } else {
            for (i in 0 until ChildListSize) {
                if (quesMarkDeatil.QuesDetail.ChildList[i].SortIndexType == 0) {
                    (fragmentList as ArrayList<Fragment>)
                            .add(MarkFragmentParentView(activity, null, quesMarkDeatil.StuAnswerList!!, i, i, typeNo))
                } else {
                    for (j in quesMarkDeatil.QuesDetail.ChildList[i].ItemList.indices) {
                        (fragmentList as ArrayList<Fragment>)
                                .add(MarkFragmentParentView(activity, null, quesMarkDeatil.StuAnswerList!!, i, j, typeNo))
                    }
                }
            }
        }
        setShowMark()
    }

    //JS点击事件处理
    inner class JSInterface(var context: Context, var imageUrls: Array<String>?) {

        @JavascriptInterface
        fun clickFunction(position: String) {
            return
        }

        @JavascriptInterface
        fun openImage(img: String, pos: Int) {
            val paths = ArrayList<String>()
            paths.add(img)
            Log.e("openImage", "$pos========点击了图片=========$img")
            ShowDialogTools.showBigImageDialog(activity, img)
        }
    }

    override fun setMenuVisibility(menuVisible: Boolean) {
        super.setMenuVisibility(menuVisible)
        if (menuVisible) {
            if (!isAddView) {
                Handler().postDelayed({
                    val parentActivity: AibkQuesMarkActivity? =
                            getActivity() as AibkQuesMarkActivity?
                    parentActivity?.getSingQuesMarkDetail(quesId, startIndex)
                    parentActivity?.setDetailListener(object : AibkQuesMarkActivity.OnDetailListener {
                        override fun getQuesDetailSuccess(quesMarkDeatilX: QuesMarkDeatil) {
                            quesMarkDeatil = quesMarkDeatilX
                            typeNo = quesMarkDeatil.QuesDetail.TypeNo
                            isAddView = true
                            rootView!!.RlGifLoading.visibility = View.GONE
                            setChildItemList()
                            initSubjectAdapter()
                            showQuestionView()
                            setEvalData(parentActivity)
                        }

                        override fun getQuesDetailFaile() {

                        }
                    })
                }, 500)
            }
        } else {
            pauseAudio()
        }

    }

    private fun setEvalData(parentActivity: AibkQuesMarkActivity) {
        val quesEntity = QuesListEntity(quesMarkDeatil)
        quesEntity.stuAnswerList?.addAll(quesMarkDeatil.StuAnswerList as MutableList)
        parentActivity.evalBody.quesList.add(quesEntity)
    }

    private fun getTlTkAnalysisAndAnswer(): String {
        var itemAnalysisAndAnswer = "<p style=\"color:#00b30d;word-break:break-all\">【参考答案】</p>"
        quesMarkDeatil.QuesDetail.ChildList.forEachIndexed { index, childMark ->
            var index = childMark.ItemList[0].SortIndex
            itemAnalysisAndAnswer = "$index${childMark.ChildAnswer}</br>$itemAnalysisAndAnswer"
        }
        itemAnalysisAndAnswer = "$itemAnalysisAndAnswer<p style=\"color:#00afff;word-break:break-all\">【答案解析】</p></br>"
        quesMarkDeatil.QuesDetail.ChildList.forEachIndexed { index, childMark ->
            if (childMark.ChildAnalysis.isNotEmpty()) {
                var index = childMark.ItemList[0].SortIndex
                itemAnalysisAndAnswer = "$index${childMark.ChildAnswer}</br>$itemAnalysisAndAnswer"
            } else {
                itemAnalysisAndAnswer += "...略</br>"
            }
        }
        return itemAnalysisAndAnswer
    }

    private fun getItemAnalysisAndAnswer(): String {
        var index = 0
        var itemAnalysisAndAnswer = ""
        quesMarkDeatil.QuesDetail.ChildList.forEach {
            var tempItemAnalysisAndAnswer = ""
            var answer = ""
            index++
            var analysis = ""
            //针对填空题的适配
            if (typeNo == "N" || typeNo == "U") {
                answer = it.ChildAnswer.replace("\$/", "或") //参考答案
                answer = answer.replace("\$、", "、")
                var childAnswerList: List<String> = answer.split("、")
                var tempAnswer = ""
                analysis = it.ChildAnalysis.replace("<WBR>", "、") //答案分析
                var childAnalysisList = analysis.split("、")
                var tempAnalysis = ""
                if (it.SortIndexType != 0) {
                    val newChildAnswerList = childAnswerList.reversed()
                    newChildAnswerList.forEachIndexed { index, s ->
                        tempAnswer = "${childItemList[childItemList.size - 1 - index].childIndex}.${s}</br>" + tempAnswer
                    }
                    if (childAnalysisList[0].isEmpty()) {
                        tempAnalysis = "...略"
                    } else {
                        val newChildAnalysisList = childAnalysisList.reversed()
                        newChildAnalysisList.forEachIndexed { index, s ->
                            tempAnalysis = "${childItemList[childItemList.size - 1 - index].childIndex}.${s}</br>" + tempAnalysis
                        }
                    }
                } else {
                    tempAnswer = answer
                    tempAnalysis = analysis
                    if (analysis.isEmpty()) {
                        tempAnalysis = "...略"
                    }
                }
                tempItemAnalysisAndAnswer = "</br></br><p style=\"color:#00b30d;word-break:break-all\">【参考答案】</p>$tempAnswer</br></br>" +
                        "<p style=\"color:#00afff;word-break:break-all\">【答案解析】</p>" + tempAnalysis + "</br>"
                itemAnalysisAndAnswer += tempItemAnalysisAndAnswer
            } else {
                val childAnswerList = it.ChildAnswer.split("\$、")
                val newChildAnswerList = childAnswerList.reversed()
                var tempAnswer = ""
                analysis = it.ChildAnalysis.replace("<WBR>", "、") //答案分析
                var childAnalysisList = analysis.split("、")
                var tempAnalysis = ""
                newChildAnswerList.forEachIndexed { index, s ->
                    tempAnswer = "${childItemList[childItemList.size - 1 - index].childIndex}.${s}</br>" + tempAnswer
                }
                if (childAnalysisList[0].isEmpty()) {
                    tempAnalysis = "...略"
                } else {
                    val newChildAnalysisList = childAnalysisList.reversed()
                    newChildAnalysisList.forEachIndexed { index, s ->
                        tempAnalysis = "${childItemList[childItemList.size - 1 - index].childIndex}.${s}</br>" + tempAnalysis
                    }
                }
                tempItemAnalysisAndAnswer = "</br></br><p style=\"color:#00b30d;word-break:break-all\">【参考答案】</p>" + tempAnswer + "</br></br>" +
                        "<p style=\"color:#00afff;word-break:break-all\">【答案解析】</p>" + tempAnalysis + "</br></br>"
                itemAnalysisAndAnswer += tempItemAnalysisAndAnswer
            }
        }
        return itemAnalysisAndAnswer
    }

    //初始化小红点
    private fun setShowMark() {
        val stuAnswerList = quesMarkDeatil.StuAnswerList!!
        //遍历所有学生，获取到每个学生的相同答题点的答案
        for (i in stuAnswerList.indices) {
            for (j in stuAnswerList[i].ChildAnswerList.indices) {
                if (stuAnswerList[i].ChildAnswerList[j].SortIndexType == 0) {
                    if (stuAnswerList[i].ChildAnswerList[j].State == 0 || stuAnswerList[i].ChildAnswerList[j].State == 1) {
                        itemList[j].isShowMark = true
                    }
                } else {
                    if (quesMarkDeatil.QuesDetail.GenreID == 48) {
                        if (stuAnswerList[i].ChildAnswerList[j].State == 0 || stuAnswerList[i].ChildAnswerList[j].State == 1) {
                            itemList[j].isShowMark = true
                        }
                    } else {
                        for (z in stuAnswerList[i].ChildAnswerList[j].ItemList.indices) {
                            if (stuAnswerList[i].ChildAnswerList[j].ItemList[z].State == 0 || stuAnswerList[i].ChildAnswerList[j].ItemList[z].State == 1) {
                                itemList[z].isShowMark = true
                            }
                        }
                    }
                }
            }
        }
    }

    //查看过后，当前列表的所有学生作答的state设置为2,小红点消失
//全部评阅完成，小红点消失
//遍历Parent.evalData 里面保存的State
// quesMarkDeatil.StuAnswerList 里面的未评阅的State也要修改, 对应的isShowMark 也要修改
    private fun doEvalJob(position: Int) {
        //遍历所有试题
        for (i in activity.evalBody.quesList.indices) {
            //遍历第i个试题所有学生的作答
            for (j in activity.evalBody.quesList[i].stuAnswerList!!.indices) {
                //找到当前界面的quesId
                val stuAnswer = activity.evalBody.quesList[i].stuAnswerList!![j]
                if (stuAnswer.QuesID == quesMarkDeatil.StuAnswerList?.get(0)!!.QuesID) {
                    //找到对应的答题点State 赋值
                    //sortIndex Type == 0
                    for (z in stuAnswer.ChildAnswerList.indices) {
                        if (stuAnswer.ChildAnswerList[z].ChildIndex == (position + 1)) {
                            if (stuAnswer.ChildAnswerList[z].SortIndexType == 0) {
                                if (stuAnswer.ChildAnswerList[z].State != 3)
                                    stuAnswer.ChildAnswerList[z].State = 2
                                for (t in stuAnswer.ChildAnswerList[z].ItemList.indices) {
                                    if (stuAnswer.ChildAnswerList[z].ItemList[t].State != 3)
                                        stuAnswer.ChildAnswerList[z].ItemList[t].State = 2
                                    activity.mTypeList!![indexA].QuesList[indexB].SortIndexList[z].IsEval = true
                                }
                            } else {
                                //sortIndexType == 1
                                if (stuAnswer.ChildAnswerList[z].ItemList[position].State != 3)
                                    stuAnswer.ChildAnswerList[z].ItemList[position].State = 2
                                activity.mTypeList!![indexA].QuesList[indexB].SortIndexList[position].IsEval = true
                            }
                        }
                    }
                }
            }
        }
    }

    private fun setStuAnswer(position: Int) {
        //遍历所有学生
        for (i in quesMarkDeatil.StuAnswerList!!.indices) {
            //遍历第i个学生的答题点,根据sortIndexType 决定给值
            for (j in quesMarkDeatil.StuAnswerList!![i].ChildAnswerList.indices) {
                if (quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[j].SortIndexType == 0) {
                    if (quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[position].State != 3)
                        quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[position].State = 2
                    for (z in quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[position].ItemList.indices) {
                        if (quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[position].ItemList[z].State != 3)
                            quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[position].ItemList[z].State = 2
                    }
                } else {
                    if (quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[j].ItemList[position].State != 3) {
                        quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[j].ItemList[position].State = 2
                        quesMarkDeatil.StuAnswerList!![i].ChildAnswerList[j].State = 2
                    }
                }
            }
        }

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.IvPlayOrPause -> {
                var quesAudioPath = quesMarkDeatil!!.QuesDetail.QuesAudio.Path
                audioPlayer = AudioPlayer(
                        activity, rootView!!.IvPlayOrPause,
                        rootView!!.SeekBarProgress,
                        rootView!!.TvAudioCurrentTime,
                        rootView!!.TvAudioTotalTime,
                        quesAudioPath,
                        AudioPlayer.ParentAudioListener {
                            val audioSpeed = quesMarkDeatil!!.QuesDetail.AudioSpeed
                            audioPlayer!!.setPlaySpeed(audioSpeed.toFloat())
                        })
            }
        }
    }

    public fun scrollToPosition(position: Int) {
        VpAnswer.setCurrentItem(position, true)
    }

}